
#ifndef _UNISTD_H
#define _UNISTD_H    1

/* This file intended to serve as a drop-in replacement for 
 *  unistd.h on Windows
 *  Please add functionality as neeeded 
 */

#include <stdlib.h>
#include <io.h>
#include <getopt.h> /* getopt from: http://www.pwilson.net/sample.html. */
#include <process.h> /* for getpid() and the exec..() family */

#ifndef srandom
#define srandom srand
#endif
#ifndef random
#define random rand
#endif
#ifndef R_OK
#define R_OK    4       /* Test for read permission.  */
#endif
#ifndef W_OK
#define W_OK    2       /* Test for write permission.  */
#endif
#ifndef F_OK
#define F_OK    0       /* Test for existence.  */
#endif
#ifndef access
#define access _access
#endif
#ifndef ftruncate
#define ftruncate _chsize
#endif
#ifndef ssize_t
#define ssize_t int
#endif
#ifndef STDIN_FILENO
#define STDIN_FILENO 0
#endif
#ifndef STDOUT_FILENO
#define STDOUT_FILENO 1
#endif
#ifndef STDERR_FILENO
#define STDERR_FILENO 2
#endif

/*
#ifndef int8_t
typedef signed char       int8_t;
#endif
#ifndef uint8_t
typedef unsigned char     uint8_t;
#endif
#ifndef int_least8_t
typedef signed char       int_least8_t;
#endif
#ifndef uint_least8_t
typedef unsigned char     uint_least8_t;
#endif
#ifndef int_fast8_t
typedef signed char       int_fast8_t;
#endif
#ifndef uint_fast8_t
typedef unsigned char     uint_fast8_t;
#endif

#ifndef int16_t
typedef signed short      int16_t;
#endif
#ifndef uint16_t
typedef unsigned short    uint16_t;
#endif
#ifndef int_least16_t
typedef signed short      int_least16_t;
#endif
#ifndef uint_least16_t
typedef unsigned short    uint_least16_t;
#endif
#ifndef int_fast16_t
typedef signed short      int_fast16_t;
#endif
#ifndef uint_fast16_t
typedef unsigned short    uint_fast16_t;
#endif

#ifndef int32_t
typedef signed int        int32_t;
#endif
#ifndef uint32_t
typedef unsigned int      uint32_t;
#endif
#ifndef int_least32_t
typedef signed int        int_least32_t;
#endif
#ifndef uint_least32_t
typedef unsigned int      uint_least32_t;
#endif
#ifndef int_fast32_t
typedef signed int        int_fast32_t;
#endif
#ifndef uint_fast32_t
typedef unsigned int      uint_fast32_t;
#endif

#ifndef int64_t
typedef signed __int64    int64_t;
#endif
#ifndef uint64_t
typedef unsigned __int64  uint64_t;
#endif
#ifndef int_least64_t
typedef signed __int64    int_least64_t;
#endif
#ifndef uint_least64_t
typedef unsigned __int64  uint_least64_t;
#endif
#ifndef int_fast64_t
typedef signed __int64    int_fast64_t;
#endif
#ifndef uint_fast64_t
typedef unsigned __int64  uint_fast64_t;
#endif

#if _INTEGRAL_MAX_BITS >= 128
#ifndef int128_t
typedef signed __int128   int128_t;
#endif
#ifndef uint128_t
typedef unsigned __int128 uint128_t;
#endif
#ifndef intmax_t
typedef signed __int128   intmax_t;
#endif
#ifndef uintmax_t
typedef unsigned __int128 uintmax_t;
#endif
#else
#ifndef intmax_t
typedef signed __int64    intmax_t;
#endif
#ifndef uintmax_t
typedef unsigned __int64  uintmax_t;
#endif
#endif

#ifndef intptr_t
typedef signed int        intptr_t;
#endif
#ifndef uintptr_t
typedef unsigned int      uintptr_t;
#endif
*/


#endif /* unistd.h  */
